import React, { Component } from 'react';
import {
  Card,
  Button,
  Table,
  Menu,
  Input,
  Divider,
  Popconfirm,
  Modal,
  message
} from 'antd';
import config from '../../../config/web.config';
import styles from './index.less';
import { getBackupData } from '../../services/user';
import { getValueWithLocalStorage } from '@/utils/authority';

const userInfo = getValueWithLocalStorage('userinfo');
export default class ContactList extends Component {
  componentDidMount() {
    config.loadlCNZZ()
  }

  async getBackupData() {
    try {
      const res =  await getBackupData(userInfo.tel);
      const url = config.HttpUrl + '/file/excel/' + res.ret.url;
      // const url = config.HttpUrl + '/file/excel/qxxzs_' + userInfo.tel + '.xlsx';
      window.open(url, 'backdata');
    } catch (error) {
      console.log(error)
    }
  }

  render() {
    return (
      <Card
        bordered={false}
        title={'数据备份'}
        style={{ marginTop: 24 }}
      >
        <div className={styles.content}>
          <Button type="primary" onClick={this.getBackupData}>下载</Button>
        </div>
      </Card>
    );
  }
}